/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ps.server;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author Ricardo
 */
public class Resource {

    //private cnServicePS cn;
    private Vector col = new Vector();
    private String error;
    private Hashtable tbl = new Hashtable();

    public String getError() {
        return error;
    }

    public Resource() {
        //cn = new cnServicePS();
    }

    public void getResource(String datos) {

        SAXParserFactory spf = SAXParserFactory.newInstance();
        try {
            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new LibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void getResourceManufacturers(String datos) {

        SAXParserFactory spf = SAXParserFactory.newInstance();
        try {
            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new ManufacturerLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void getResourceSuppliers(String datos) {

        SAXParserFactory spf = SAXParserFactory.newInstance();
        try {
            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new SupplierLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void getResourceCategories(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new CategoryLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void getResourceCombinations(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new CombinationLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void getResourceProduct_features(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new Product_featureLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void getResourceProducts(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new ProductLibraryXMLReader(col));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void getResourceConfigurations(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new ConfigurationsLibraryXMLReader(tbl));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void getResourceTaxes(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new TaxesLibraryXMLReader(tbl));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

       public void getResourceTax_rules(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new Tax_RulesLibraryXMLReader(tbl));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
           public void getResourceTax_rule_groups(String datos) {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();

            SAXParser sp = spf.newSAXParser();
            InputStream is = new ByteArrayInputStream(datos.getBytes());

            sp.parse(is, new Tax_Rules_GroupsLibraryXMLReader(tbl));
            System.out.print(sp.getXMLReader().toString());
        } catch (IOException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(Resource.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public Vector GetColeccion() {
        return this.col;
    }

    public Hashtable GetConfig() {
        return this.tbl;
    }
}
